package com.unytech.watersoil.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.dispatcher.ApplicationMap;
import org.apache.struts2.dispatcher.RequestMap;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.interceptor.ApplicationAware;
import org.apache.struts2.interceptor.CookiesAware;
import org.apache.struts2.interceptor.ParameterAware;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

public abstract class BaseAction extends ActionSupport implements ServletRequestAware, ServletResponseAware, 
	SessionAware, RequestAware, ApplicationAware, CookiesAware, ParameterAware{
	final protected Log logger = LogFactory.getLog(getClass());
	//BaseService service = null;  //每一个Action都需要一个service，可注入需要的现类
	
	//通过IoC的方式来获得Action封装后的 request,response,session  
	private ApplicationMap application;
	private HttpServletRequest request;  
	private RequestMap requestm;
    private HttpServletResponse response;  
    private SessionMap<String, Object> session;
    
	private String message; //记录返回消息
	
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public HttpServletRequest getRequest() {
		return request;
	}
	public HttpServletResponse getResponse() {
		return response;
	}
	public SessionMap<String, Object> getSession() {
		return session;
	}
	//必须有的方法，为注入自动注入所用
	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}
	public void setServletRequest(HttpServletRequest request) {
		this.request = request; 
	}
	public void setSession(Map<String, Object> map) {
		this.session = (SessionMap<String, Object>) map;
	}
	public void setApplication(Map<String, Object> map) {
		this.application = (ApplicationMap) map;
	}
	public ApplicationMap getApplication() {
		return application;
	}
	public void setParameters(Map<String, String[]> arg0) {
		// TODO Auto-generated method stub
		
	}
	public void setCookiesMap(Map<String, String> arg0) {
		// TODO Auto-generated method stub
		
	}
	public void setRequest(Map<String, Object> arg0) {
		// TODO Auto-generated method stub
		
	}
	public void setRequestm(RequestMap requestm) {
		this.requestm = requestm;
	}
	public RequestMap getRequestm() {
		return requestm;
	}
	
}
